#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include<math.h>

int main() {
    int n = 0;
    scanf_s("%d", &n);
    int arr[100000];
    while (n) {
        scanf_s("%d", &arr[n - 1]);
        n--;
        printf("%d ", arr[n]);
    }
    for (int i = 1; i < n; i++) {
        int max = 0;
     
        if (max < arr[i]) {
            
            max = arr[0];
            max = arr[i];
            arr[i] = 0;
        }
        printf("%d ", max);
    }
    return 0;
}